/**
 * 
 */
package jMiiEditor.gui.miifilechooser;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import jMiiEditor.mii.Mii;
import jMiiEditor.mii.checker.MiiCheckerFileObject;
import jMiiEditor.mii.checker.impl.MiiCheckerFileObjectDefaultImpl;

/**
 * @author CC
 *
 */
public class MiiFileObjectDefaultImpl 
    implements MiiFileObject, Serializable
{
    private static final long serialVersionUID = 1L;
    /** @serial */
    private File aFile;
    
    /**
     * @param aFile
     */
    public MiiFileObjectDefaultImpl( File aFile )
    {
        this.aFile = aFile;
    }

    @Override
    public String getDisplayPath()
    {
        return aFile.getPath();
    }
    
    @Override
    public String getName()
    {
        return aFile.getName();
    }
    
    @Override
    public boolean exists()
    {
        return aFile.exists();
    }

    @Override
    public Mii loadMii() throws IOException
    {
        return new Mii( aFile );
    }
    
    @Override
    public void saveMii(Mii mii) throws IOException
    {
        mii.save( aFile );
    }

    @Override
    public MiiCheckerFileObject getMiiCheckerFileObject()
    {
        return new MiiCheckerFileObjectDefaultImpl( aFile );
    }

    @Override
    public MiiFileObject getMiiFileObject(
            MiiCheckerFileObject aMiiCheckerFileObject 
            )
    {
        File f = File.class.cast( 
                aMiiCheckerFileObject.getInternalObject()
                );
        
        return new MiiFileObjectDefaultImpl( f );
    }

}
